/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DbConnection;

/**
 *
 * @author Home
 */
import java.sql.*;
import javax.swing.*;

public class ConnectionManager {

    Connection conn = null;

    public static Connection ConnecrDb(){
        try {
            // The driver allows you to query the database with Java
            // forName dynamically loads the class for you

            Class.forName("org.postgresql.Driver");

            // DriverManager is used to handle a set of JDBC drivers
            // getConnection establishes a connection to the database
            // You must also pass the userid and password for the database

            Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Project_pas", "postgres", "Passw0rd");

            // Statement objects executes a SQL query
            // createStatement returns a Statement object
            
            return conn;
    
        } catch (Exception ex) {

            // String describing the error
            JOptionPane.showMessageDialog(null, ex);
            return null;

        }

    }

}
